package br.com.cast.syscast.persistencia;

import java.sql.Connection;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.hibernate.Session;

public class DAOBase {
	
	@PersistenceContext(unitName = "persistencia")
	private EntityManager entityManager;
	
	private Connection connection;
	
	protected Connection getConnection() {
		if (connection == null) {
//			try {
//				connection = dataSource.getConnection();
//			} catch (SQLException e) {
//				throw new RuntimeException(e);
//			}
		}
		return connection;
	}
	
	protected EntityManager getEntityManager() {
		return this.entityManager;
	}

	protected Session getHibernateCurrentSession() {
		return (Session) getEntityManager().getDelegate();
	}

}
